package cn.com.cym.gamezao.test;

import org.jsoup.Connection;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

import java.io.IOException;

public class Wikipedia {
    public static void main(String[] args) throws IOException {
        final Connection connect = Jsoup.connect("https://jsoup.org/download");
        //connect.get()
        Document doc = Jsoup.connect("https://jsoup.org/download").get();
        System.out.println(doc.body().html());
        //log(doc.html());

        Elements newsHeadlines = doc.select("h2");
        for (Element headline : newsHeadlines) {
            log("",headline.html());
            //log("%s\n\t%s", headline.attr("title"), headline.absUrl("href"));
        }
    }

    private static void log(String msg, String... vals) {
        System.out.println(String.format(msg, vals));
    }
}
